<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>login</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
            width: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background: url(background.png) no-repeat 0px 0px;
            background-repeat: no-repeat;
            background-size: 100% 100%;
            -moz-background-size: 100% 100%;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
        }

        #loginDiv {
            width: 400px;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 400px;
            background-color: rgba(75, 81, 95, 0.3);
            box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);
            border-radius: 250px;
        }


        p {
            margin-top: 30px;
            margin-left: 20px;
            color: azure;
        }

        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 30px;
            width: 140px;
            background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            padding-left: 10px;
        }

        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
        }
    </style>
    <style type="text/css">
        input::-ms-input-placeholder{text-align: center;}
        input::-webkit-input-placeholder{text-align: center;}
    </style>
</head>

<body >
<div id="loginDiv">
    <form id="form" action="http://localhost:8080/library/login"  method="get">
        <h1 style="text-align: center;color: aliceblue;">立即登录</h1>
        <p>账号:<input id="username" type="text" name="username"></p>

        <p>密码:<input id="password" type="password" placeholder="密码长度至少为6位" name="password"></p>
        <p style="text-align: center;color: darkgray;"><a href="#">忘记密码?</a></p>
        <div style="text-align: center;margin-top: 30px;">
            <input id="sm1" type="submit"  value="登录" />
            <input type="button" class="button" value="注册" onclick="register_click()">
        </div>
    </form>
</div>
    <script type="text/javascript">
        var sub1=document.getElementById('sm1');
         //注册按钮跳转
        function register_click(){
            window.location.href="http://localhost:8080/library/register.html";
        }

        window.onload=function(){
            var name=document.getElementById('username').value;
            var pass=document.getElementById('password').value;
        //获取注册时存储在localStorage中的值
            sub1.onkeydown=function (){
                if(name!=''&&pass!=''&&pass.length>6){
                if(sub1.keyCode==13){
                    window.location.href="http://localhost:8080/library/login";
                }
            }else if(pass.length<=6&&pass!=''){
                    alert('密码不能少于6位');
                }else{
                    alert('账号或密码不能为空!');
                }
            }

        }
    </script>


</body>

<html/>